<?php
require_once("AsteriskManagerM/config.php");
include("AsteriskManagerM/sesvars.php");
if(isset($_SESSION['QSTATS']['hideloggedoff'])) {
    $ocultar=$_SESSION['QSTATS']['hideloggedoff'];
} else {
    $ocultar="false";
}
?>


<head>
<style type="text/css">
.hidden{
	display: none;
}

#box-table-b
{
	font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
	font-size: 12px;
	text-align: center;
	border-collapse: collapse;
	border-top: 7px solid #8FC122;
	border-bottom: 7px solid #8FC122;
}
#box-table-b th
{
	font-size: 13px;
	font-weight: normal;
	padding: 8px;
	background: #F2FBE6;
	border-right: 1px solid #8FC122;
	border-left: 1px solid #8FC122;
	color: #039;
}
#box-table-b td
{
	padding: 8px;
	background: #F2FBE6; 
	border-right: 1px solid #8FC122;
	border-left: 1px solid #8FC122;
	color: #669;
}
</style>
<script type="text/javascript">
		var aJaxURL	= "server-side/call/incomming_m.action.php";		//server side folder url
		var tName	= "example";										//table name
		var fName	= "add-edit-form";									//form name
		var file_name = '';
		var rand_file = '';

		$(document).ready(function () {

			runAjax();
			
			GetDate("search_start");
			GetDate("search_end");
			var start 	= $("#search_start").val();
			var end 	= $("#search_end").val();
			LoadTable(start, end);
			/* Add Button ID, Delete Button ID */
			GetButtons("add_button", "","");
			SetEvents("add_button", "", "", tName, fName, aJaxURL);

		});

		function LoadTable(start, end){
			/* Table ID, aJaxURL, Action, Colum Number, Custom Request, Hidden Colum, Menu Array */
			GetDataTable(tName, aJaxURL, "get_list",9, "start=" + start + "&end=" + end, 0, "", 1, "desc");
		}

		$(document).on("click", ".download", function () {
            var link = $(this).attr("str");
            link = 'http://212.72.155.175:8181/records/' + link;

            window.open(link, 'chatwindow', "width=420,height=230,resizable=yes,scrollbars=yes,status=yes");
        });

		function LoadDialog(){

			/* Dialog Form Selector Name, Buttons Array */
			GetDialog(fName, 1200, "auto", "cust");
			var id = $("#incomming_id").val();
			var cat_id = $("#category_parent_id").val();
			$( ".calls" ).button({
			      icons: {
			        primary: " ui-icon-contact"
			      }
			});
			$( ".download" ).button({
			      icons: {
			        primary: " ui-icon-contact"
			      }
			});
		}

		function CloseDialog(){
			$("#" + fName).dialog("close");
		}

	    function run(number){

	    	param 			= new Object();
		 	param.act		= "get_add_page";
		 	param.number	= number;

	    	$.ajax({
		        url: aJaxURL,
			    data: param,
		        success: function(data) {
					if(typeof(data.error) != 'undefined'){
						if(data.error != ''){
							alert(data.error);
						}else{
							$("#add-edit-form").html(data.page);
							LoadDialog();
						}
					}
			    }
		    });
		    }

	    function runAjax() {
            $.ajax({
            	async: true,
            	dataType: "html",
		        url: 'AsteriskManagerM/liveState.php',
			    data: 'sesvar=hideloggedoff&value=true',
		        success: function(data) {
							$("#jq").html(data);
			    }
            }).done(function(data) {
                setTimeout(runAjax, 1000);
            });
        }

	    $(document).on("change", "#search_start", function () {
	    	var start	= $(this).val();
	    	var end		= $("#search_end").val();
	    	LoadTable(start, end);
	    });
	    
	    $(document).on("change", "#search_end", function () {
	    	var start	= $("#search_start").val();
	    	var end		= $(this).val();
	    	LoadTable(start, end);
	    });

    </script>
</head>

<body>

<table style="width: 1100px; margin: 0 0 0 100px; padding-top:25px; display: block;">
		<tr style="width: 800px">
			<td>
            	<h2 align="center">შემომავალი ზარები</h2>
                <div id="button_area" style="margin-top: 10px;">
	            	<div class="left" style="width: 220px; ">
	            		<label for="search_start" class="left" style="margin: 5px 0 0 9px;">დასაწყისი</label>
	            		<input type="text" style="height: 13px; width: 110px; margin-left: 5px;" name="search_start" id="search_start" class="inpt left"/>
	            	</div>
	            	<div class="right" style="">
	            		<label for="search_end" class="left" style="margin: 5px 0 0 9px;">დასასრული</label>
	            		<input type="text" style="height: 13px; width: 110px; margin-left: 5px;" name="search_end" id="search_end" class="inpt left" />
            		</div>	
            	</div>
                <table class="display" id="example">
                    <thead>
                        <tr id="datatable_header">
                            <th>ID</th>
                            <th style="width: 50px;" >№</th>
                            <th style="width: 150px;">თარიღი</th>
                            <th style="width: 150px;">კატეგორია</th>
                            <th style="width: 150px;">ტელეფონი</th>
                            <th style="width: 150px;">შინაარსი</th>
                        </tr>
                    </thead>
                    <thead>
                        <tr class="search_header">
                            <th class="colum_hidden">
                            	<input type="text" name="search_id" value="ფილტრი" class="search_init" style=""/>
                            </th>
                            <th>
                            	<input type="text" name="search_number" value="ფილტრი" class="search_init hidden-input" style=""></th>
                            <th>
                                <input type="text" name="search_date" value="ფილტრი" class="search_init" style="width: 100px;"/>
                            </th>                            
                            <th>
                                <input type="text" name="search_category" value="ფილტრი" class="search_init" style="width: 80px;" />
                            </th>
                            <th>
                                <input type="text" name="search_phone" value="ფილტრი" class="search_init" style="width: 90px;"/>
                            </th>
                            <th>
                                <input type="text" name="search_category" value="ფილტრი" class="search_init" style="width: 90px;" />
                            </th>
                            
                        </tr>
                    </thead>
                </table>
	            <div class="spacer">
	         </div>
	    <td style="width: 20px;">
		   &nbsp;
		</td>
		<td style="width: 450px;">
		   <div id="jq" style="width: 450px; position: fixed;"></div>
		</td>
	</tr>
</table>

    <!-- jQuery Dialog -->
    <div  id="add-edit-form" class="form-dialog" title="შემომავალი ზარი">
	</div>

	<!-- jQuery Dialog -->
	<div id="last_calls" title="ბოლო ზარები">
	</div>
</body>
